using System;
using System.ComponentModel.DataAnnotations;
using InfoTech.VinhSon.Bussiness;

namespace InfoTech.VinhSon.Models
{
    [Serializable]
    public partial class CategoryModel
    {

        #region Constructor

        public CategoryModel()
        {
        }

        public CategoryModel(Category value)
        {
            Id = value.Id;
            if (value.Parent != null)
                ParentId = value.Parent.Id;
            Name = value.Name;
            Description = value.Description;
            Detail = value.Detail;
            Activated = value.Activated ?? false;
            Url = value.Url;
            IsShowMenu = value.IsShowMenu ?? false;
            Priority = value.Priority;
            GroupIndex = value.GroupIndex;
            GroupPriority = value.GroupPriority;
            Status = value.Status ?? 0;
        }

        #endregion

        #region Fields

        private System.Int32 _Id;

        private System.Int32? _ParentId;

        private System.String _Name;

        private System.String _Description;

        private System.String _Detail;

        private System.Boolean _Activated;

        private System.String _Url;

        private System.Boolean _IsShowMenu;

        private System.Int32? _Priority;

        private System.Int32? _GroupIndex;

        private System.Int32? _GroupPriority;

        private System.Int32 _Status;

        #endregion

        #region Properties

        //[Required]
        //[Range(0, 0]
        //[StringLength(0)]
        public System.Int32 Id
        {
            get
            {
                return _Id;
            }
            set
            {
                _Id = value;
            }
        }

        //[Required]
        //[Range(0, 0]
        //[StringLength(0)]
        public System.Int32? ParentId
        {
            get
            {
                return _ParentId;
            }
            set
            {
                _ParentId = value;
            }
        }

        [Required]
        //[Range(0, 0]
        [StringLength(200)]
        public System.String Name
        {
            get
            {
                return _Name;
            }
            set
            {
                _Name = value;
            }
        }

        //[Required]
        //[Range(0, 0]
        [StringLength(1073741823)]
        public System.String Description
        {
            get
            {
                return _Description;
            }
            set
            {
                _Description = value;
            }
        }

        //[Required]
        //[Range(0, 0]
        [StringLength(1073741823)]
        public System.String Detail
        {
            get
            {
                return _Detail;
            }
            set
            {
                _Detail = value;
            }
        }

        //[Required]
        //[Range(0, 0]
        //[StringLength(0)]
        public System.Boolean Activated
        {
            get
            {
                return _Activated;
            }
            set
            {
                _Activated = value;
            }
        }

        //[Required]
        //[Range(0, 0]
        [StringLength(200)]
        public System.String Url
        {
            get
            {
                return _Url;
            }
            set
            {
                _Url = value;
            }
        }

        //[Required]
        //[Range(0, 0]
        //[StringLength(0)]
        public System.Boolean IsShowMenu
        {
            get
            {
                return _IsShowMenu;
            }
            set
            {
                _IsShowMenu = value;
            }
        }

        //[Required]
        //[Range(0, 0]
        //[StringLength(0)]
        public System.Int32? Priority
        {
            get
            {
                return _Priority;
            }
            set
            {
                _Priority = value;
            }
        }

        //[Required]
        //[Range(0, 0]
        //[StringLength(0)]
        public System.Int32? GroupIndex
        {
            get
            {
                return _GroupIndex;
            }
            set
            {
                _GroupIndex = value;
            }
        }

        //[Required]
        //[Range(0, 0]
        //[StringLength(0)]
        public System.Int32? GroupPriority
        {
            get
            {
                return _GroupPriority;
            }
            set
            {
                _GroupPriority = value;
            }
        }

        //[Required]
        //[Range(0, 0]
        //[StringLength(0)]
        public System.Int32 Status
        {
            get
            {
                return _Status;
            }
            set
            {
                _Status = value;
            }
        }

        #endregion

        #region Operators

        public void Update(Category value)
        {
            // value.Id = Id;
            value.Name = Name;
            value.Description = Description;
            value.Detail = Detail;
            value.Activated = Activated;
            value.Url = Url;
            value.IsShowMenu = IsShowMenu;
            value.Priority = Priority;
            value.GroupIndex = GroupIndex;
            value.GroupPriority = GroupPriority;
            //value.Status = Status;
        }

        public static implicit operator CategoryModel(Category obj)
        {
            return new CategoryModel(obj);
        }

        public static implicit operator Category(CategoryModel obj)
        {
            Category value = new Category();
            obj.Update(value);
            return value;
        }

        #endregion

    }
}
